<%@page contentType="text/html; charset=utf-8" language="java" errorPage="error.jsp"%>
<%@page import="com.greendragon.persistence.domain.User"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
String subtitle = "添加新用户";
String scripts = "/static/js/admin.js?v=0.0.1,/static/js/Validform_min.js";
String styles = "/static/css/admin.css?v=0.0.1,/static/css/validation.css?v=0.0.1";
%>
<%@ include file="/include/header.jspf"%>
<script>
$(document).ready(function() {
	new GD.admin.init("account-new");
	$("#regForm").Validform({
		btnSubmit:"#btn_sub",
		tiptype:function(msg,o,cssctl){
			if(o.obj){
					var objtip=o.obj.parent().parent().find(".Validform_checktip");
					cssctl(objtip,o.type);
					objtip.text(msg);
				}
		},
		tipSweep:true,
		postonce:true
	});
});
</script>
<body>
<div id="wrap">
<div id="content">
   <%@include file="include/body-header.jspf"%>
   <div id="bodier">
		<jsp:include page="include/adminmenu.jspf"/>
		<div id="body-content">
			<div id="content-wrap">
				<c:if test="${param.add=='true'}">
					<div id="setting-updated" class="radius5">用户 <span>${name}</span> 已添加。</div>
				</c:if>
				<div class="icon32 newuser-icon"></div>
				<h2 class="title">添加新用户</h2>
				<div class="cleft">用户可以由自己 <a href="/account/signup.jsp" target="_blank">注册</a>，或者您可以在这里创建。</div>
				<form id="regForm" action="useradd.do" method="post">
					<table class="form-table">
						<tr>
							<th><label for="username">用户名<span class="gray"> (必填)</span></label></th>
							<td class="input_content">
								<input id="username" class="regular-text radius5" type="text" name="name" value='${name}' ajaxurl="/account/asnynamecheck.do" datatype="e" nullmsg="请输入邮箱地址" errormsg="请输入邮箱地址"/>
							</td>
							<td class="checktip">			
							<c:choose>
							   <c:when test="${null!=errors.name}">    
							   <div class="Validform_checktip Validform_wrong">
									<c:forEach items="${errors.name}" var="err">
										${err}
									</c:forEach>
								</div>
							   </c:when>
							   <c:otherwise>  
								<div class="Validform_checktip gray">请输入常用的邮箱地址</div>
							   </c:otherwise>
							</c:choose>
							</td>
						</tr>
						<tr>
							<th><label for="nickname">昵  称<span class="gray"> (必填)</span></label></th>
							<td>
								<input id="nickname" class="regular-text radius5" type="text" name="nickname" value='${nickname}' datatype="s1-16" nullmsg="请输入昵称" errormsg="昵称最多12个字符"/>
							</td>
							<td>			
							<c:choose>
							   <c:when test="${null!=errors.nickname}">    
							   <div class="Validform_checktip Validform_wrong">
									<c:forEach items="${errors.nickname}" var="err">
										${err}
									</c:forEach>
								</div>
							   </c:when>
							   <c:otherwise>  
								<div class="Validform_checktip gray">昵称最多12个字符</div>
							   </c:otherwise>
							</c:choose>
							</td>
						</tr>
						<tr>
							<th><label for="password">密  码<span class="gray"> (必填)</span></label></th>
							<td>
								<input id="password" class="regular-text radius5" type="password" name="password" datatype="s6-20" nullmsg="请设置密码" errormsg="密码范围在6~20位之间，不能使用空格"/>
							</td>
							<td>			
							<c:choose>
							   <c:when test="${null!=errors.password}">    
							   <div class="Validform_checktip Validform_wrong">
									<c:forEach items="${errors.password}" var="err">
										${err}
									</c:forEach>
								</div>
							   </c:when>
							   <c:otherwise>  
								<div class="Validform_checktip gray">密码范围在6~20位之间，不能使用空格</div>
							   </c:otherwise>
							</c:choose>
							</td>
						</tr>
						<tr>
							<th><label for="confirmpw">确认密码<span class="gray"> (必填)</span></label></th>
							<td><input id="confirmpw" class="regular-text radius5" type="password" name="confirmPassword" datatype="*" recheck="password" errormsg="您两次输入的账号密码不一致"/>
							</td>
							<td>			
							<c:choose>
							   <c:when test="${null!=errors.confirmPassword}">    
							   <div class="Validform_checktip Validform_wrong">
									<c:forEach items="${errors.confirmPassword}" var="err">
										${err}
									</c:forEach>
								</div>
							   </c:when>
							   <c:otherwise>  
								<div class="Validform_checktip gray">两次输入密码须一致</div>
							   </c:otherwise>
							</c:choose>
							</td>
						</tr>
						<tr>
							<th><label for="web">网站</label></th>
							<td colspan="2">
								<input id="web" class="regular-text radius5" type="text" name="website" value="http://" value="${website}"/>
							</td>
						</tr>
						<tr>
							<th><label for="phone">常用电话</label></th>
							<td colspan="2">
								<input id="phone" class="regular-text radius5" type="text" name="phone" value="${phone}"/>
							</td>
						</tr>
						<tr>
							<th><label for="role">角色</label></th>
							<td colspan="2">
								<select id="role" name="role" class="regular-text radius5">
									<option value="user"<c:if test="${role==''||role=='user'}"> selected="selected"</c:if>>普通用户</option>
									<option value="admin"<c:if test="${role=='admin'}"> selected="selected"</c:if>>管理员</option>
								</select>
							</td>
						</tr>
						<tr>
							<th><label for="sendPassword">发送密码？</label></th>
							<td colspan="2">
								<label for="sendPassword">
								<input id="sendPassword" type="checkbox" name="sendPassword"<c:if test="${sendPassword==true}"> checked="checked"</c:if>/> 使用电子邮件发送这个新密码给新用户。
								</label>
							</td>
						</tr>
					</table>
					<input type="submit" id="btn_sub" class="button-blue" value="添加新用户"/>
				</form>
			</div>
		</div>
		<div class="clear"></div>
	</div>
 </div>
 </div>
<%@include file="include/footer.jspf"%>